/*
==============================================================================
Megapayment Internet Portal
Copyright (c) 2010 VNPT ePay JSC
==============================================================================
*/
using System;
using System.Collections;
using System.Web;

/**
 * Class to process request variables
 * @author Dinh Quoc Dat
 * @version 0.12.2712 alpha
 */

public static class request {

  /**
   * Initialise data
   */
  public static void init() {
    //
  }

  /**
   * Get request variable value in query string (URL)
   * @param string var_name
   * @return string Variable value in http request
   */
  public static string get_url_var(string var_name) {
    if (HttpContext.Current.Request.QueryString[var_name]!=null)
      return (string)HttpContext.Current.Request.QueryString[var_name];
    else
      return null;
  }
  
  /**
   * Get request variable value in POST
   * @param string var_name
   * @return string Variable value in http request
   */
  public static string get_form_var(string var_name) {
    if (HttpContext.Current.Request.Form[var_name]!=null)
      return (string)HttpContext.Current.Request.Form[var_name];
    else
      return null;
  }

  /**
   * Get file in POST
   * @param string name_in_form The value of 'name' attribute in html
   * @return HttpPostedFile 
   */
  public static HttpPostedFile get_form_file(string name_in_form) {
    if (HttpContext.Current.Request.Files.Get(name_in_form)!=null)
      return HttpContext.Current.Request.Files.Get(name_in_form);
    else
      return null;
  }
  
  /**
   * Get request variable values in POST (array)
   * @param string var_name
   * @return string[] Variable values in http request
   */
  public static string[] get_form_vars(string var_name) {
    return HttpContext.Current.Request.Form.GetValues(var_name+"[]");
  }  
}